#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=60;
typedef long long LL;
LL a[maxn];
LL cal(LL x){
    LL i=0;
    for(i=0;(1<<i)<=1e9 ;i++){
        if((1<<i)>=x){
            LL cnt1=abs( (1<<i)-x);
            LL cnt2=abs(x-(1<<(i-1)));
            if(cnt1<cnt2) return i;
            else return i-1;
        }

    }
    if((1<<i)>1e9) return i-1;
}
void solve(){
    LL n;cin>>n;
    for(LL i=1;i<=n;i++) cin>>a[i];
    for(LL i=1;i<=n;i++){
        LL b=cal(a[i]);
        cout<<(1<<b)<<" ";
    }
    cout<<endl;
}
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL t;cin>>t;
  while(t--){
    solve();
  }
return 0;
}
